package io.github.eric.urpc.standalone.client;

import io.github.eric.urpc.core.conn.Connection;
import io.github.eric.urpc.core.conn.ConnectionListener;
import io.github.eric.urpc.standalone.common.msg.UserLogin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public class ClientConnListener implements ConnectionListener {
    private static final Logger LOGGER = LoggerFactory.getLogger(ClientConnListener.class);

    private String userId;
    private String userName;

    @Override
    public void onConnected(Connection conn) {
        UserLogin userLogin = new UserLogin();
        userLogin.setUserId(userId);
        userLogin.setUserName(userName);
        conn.sendAsync(userLogin);

        LOGGER.info("我的UserId是{}, userName是{}, connId {}", userLogin.getUserId(), userLogin.getUserName(), conn.getId());
    }

    @Override
    public void onDisConnected(Connection conn) {

    }

    @Override
    public void onAccepted(Connection conn) {

    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
}
